package com.example.shop_2302.fg

import androidx.lifecycle.viewModelScope
import com.example.base.entity.CategoryEntity
import com.example.base.entity.Res
import com.example.base.mvvm.BaseViewModel
import com.example.shop_2302.utils.SingleLiveData
import kotlinx.coroutines.launch

class CategoryViewModel:BaseViewModel() {

    val cateSuccess = SingleLiveData<Res<CategoryEntity>>()
    val cateFail = SingleLiveData<String>()
    fun category(){
        viewModelScope.launch {
            try {
                cateSuccess.postValue(apiServer.category())
            }catch (e:Exception){
                cateFail.postValue(e.message.toString())
            }
        }
    }
}